package com.huayue.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.huayue.entity.PurchaseOrderDetails;
import com.huayue.util.PageHelper;
import com.mysql.DBHelper;

/**
 * 请购订单详情
 * 
 */
@Component
public class PurchaseOrderDetailsDao implements BaseDao<PurchaseOrderDetails> {
    @Override
    public int insert(PurchaseOrderDetails entity) {
        return DBHelper.executeUpdate(
            "insert into purchase_order_details (purchase_order_id, product_id, price, number, cause, is_status) values ((select MAX(id) from purchase_order), ?, ?, ?, ?, 0);",
            entity.getProductId(), entity.getOnePrice(), entity.getNumber(), entity.getCause());
    }

    @Override
    public int update(PurchaseOrderDetails entity) {
        return 0;
    }

    @Override
    public int delete(PurchaseOrderDetails entity) {
        return 0;
    }

    @Override
    public List<Map<String, Object>> findAll(Object... obj) {
        return null;
    }

    @Override
    public List<Map<String, Object>> findPage(PageHelper page, Object... obj) {
        return null;
    }

    @Override
    public Map<String, Object> findOne(PurchaseOrderDetails entity) {
        return null;
    }

    @Override
    public int count(Object... obj) {
        return 0;
    }

    public List<Map<String, Object>> findDetails(String id) {
        return DBHelper.executeQuery(
            "select rod.*,p.unit,p.product_number from purchase_order_details rod left join product p on rod.product_id=p.id where rod.is_deleted=0 and rod.purchase_order_id=?",
            id);
    }
}
